//
//  LrcsTool.m
//  MyMusic
//
//  Created by ioser on 17/5/7.
//  Copyright © 2017年 ioser. All rights reserved.
//

#import "LrcsTool.h"
#import "LrcsModel.h"

@implementation LrcsTool

+ (NSArray *)GetlrcLine:(NSString *)lrcName
{
    // 加载plist文件
    NSString *path = [[NSBundle mainBundle] pathForResource:lrcName ofType:nil];
    NSString *lrc = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
    NSArray *lineLrc = [lrc componentsSeparatedByString:@"\n"];
    NSMutableArray *tempArray = [NSMutableArray array];
    for (NSString *eachLineLrc in lineLrc) {
        // 过滤不需要显示的歌词
        if ([eachLineLrc hasPrefix:@"[ti"] || [eachLineLrc hasPrefix:@"[ar"] || [eachLineLrc hasPrefix:@"[al"] || ![eachLineLrc hasPrefix:@"["]) {
            continue;
        }
        NSLog(@"%@\n",eachLineLrc);
        // 把每行的 歌词 传到工具类里面进行截取
        LrcsModel *model = [LrcsModel LrcsName:eachLineLrc];
        
        [tempArray addObject:model];
    }

    return tempArray;
}

@end
